<?php
/*
 * 用户model文件
 */
include DOCMENT_ROOT.'/Framework/model.class.php';
class userModel extends model{
   public function __construct(){
       parent::connectMysqlDB("zuoye");
    }
    
    /*
     * 验证某些字段是否重复
     * @return boolean true不重复 false重复
     */
   public function checkField($where){
    if($where==""){
	return false;
	}else{
	$sql = "select * from user where $where";
	$arr = $this->mysql->select($sql);
            if($arr==null){
		return true;
            }else{
		return false;	
            }
         }
	}
   /*
    * 添加记录
    */
    public function addUser($name,$pwd,$nickName,$eamil,$tel){
        $pwd=md5($pwd);
	$sql = "insert into user(name,pwd,nick_name,email,tel)values('$name','$pwd','$nickName','$eamil','$tel')";
	$result = $this->mysql->add($sql);
	return $result;
	}
   /*
    * 查询记录
    */
   public function login($name,$pwd) {
     $sql = "select count(*) as num from user where name='$name' and pwd = '$pwd' ";
     $result = $this->mysql->login($sql);
        if(!empty($result)) {
            return true;
        }else{
        return false;
        }
    }
    //查询
    public function userselect($id){
       $sql="select * from user where id=$id";
        $arr = $this->mysql->select($sql);
        return $arr;
    }
  //修改
    public function updateOne($nick_name,$pwd,$id,$email,$tel){
        $sql="update user set nick_name = '$nick_name',pwd='$pwd',email = '$email',tel='$tel' where id= $id";
        $arr = $this->mysql->update($sql);
        return $arr;
    }
}
